package cn.secby.orders.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.secby.common.log.annotation.Log;
import cn.secby.common.log.enums.BusinessType;
import cn.secby.common.security.annotation.RequiresPermissions;
import cn.secby.orders.domain.AuditRecord;
import cn.secby.orders.service.IAuditRecordService;
import cn.secby.common.core.web.controller.BaseController;
import cn.secby.common.core.web.domain.AjaxResult;
import cn.secby.common.core.utils.poi.ExcelUtil;
import cn.secby.common.core.web.page.TableDataInfo;

/**
 * 审核记录Controller
 * 
 * @author shenkunlin
 * @date 2025-05-06
 */
@RestController
@RequestMapping("/auditRecord")
public class AuditRecordController extends BaseController
{
    @Autowired
    private IAuditRecordService auditRecordService;

    /**
     * 查询审核记录列表
     */
    @RequiresPermissions("orders:auditRecord:list")
    @GetMapping("/list")
    public TableDataInfo list(AuditRecord auditRecord)
    {
        startPage();
        List<AuditRecord> list = auditRecordService.selectAuditRecordList(auditRecord);
        return getDataTable(list);
    }

    /**
     * 导出审核记录列表
     */
    @RequiresPermissions("orders:auditRecord:export")
    @Log(title = "审核记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AuditRecord auditRecord)
    {
        List<AuditRecord> list = auditRecordService.selectAuditRecordList(auditRecord);
        ExcelUtil<AuditRecord> util = new ExcelUtil<AuditRecord>(AuditRecord.class);
        util.exportExcel(response, list, "审核记录数据");
    }

    /**
     * 获取审核记录详细信息
     */
    @RequiresPermissions("orders:auditRecord:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(auditRecordService.selectAuditRecordById(id));
    }

    /**
     * 新增审核记录
     */
    @RequiresPermissions("orders:auditRecord:add")
    @Log(title = "审核记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AuditRecord auditRecord)
    {
        return toAjax(auditRecordService.insertAuditRecord(auditRecord));
    }

    /**
     * 修改审核记录
     */
    @RequiresPermissions("orders:auditRecord:edit")
    @Log(title = "审核记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AuditRecord auditRecord)
    {
        return toAjax(auditRecordService.updateAuditRecord(auditRecord));
    }

    /**
     * 删除审核记录
     */
    @RequiresPermissions("orders:auditRecord:remove")
    @Log(title = "审核记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(auditRecordService.deleteAuditRecordByIds(ids));
    }
}
